﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 泛型02
{
    class Program
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            int c = 1;
            int d = 2;
            p.Swap<int>(ref c, ref d);
            Console.WriteLine(c + " " + d);

            string a = "1";
            string b = "2";
            p.Swap<string>(ref a, ref b);
            Console.WriteLine(a + " " + b);
        }

        public void Swap<T>(ref T a, ref T b)
        {
            T temp = a;
            a = b;
            b = temp;
        }
    }
}
